/*
* @Author: Adolphus.Yao
* @Date:   2019-08-27 21:27:20
* @Last Modified by:   Adolphus.Yao
* @Last Modified time: 2019-08-27 21:27:40
*/
package leetcode

func TwoSum(nums []int, target int) []int {
    m := make(map[int]int)
    for i, num := range nums {
        key := target - num
        if j, ok := m[key]; ok {
            return []int{j, i}
        }
        m[nums[i]] = i
    }
    return []int{}
}